{% extends "base_generic.html" %}

{% block content %}

<h1>Title: {{ book.title }}</h1>

<p><strong>Author:</strong> <a href="{{ book.author.get_absolute_url }}">{{ book.author }}</a></p>
<p><strong>Summary:</strong> {{ book.summary }}</p>
<p><strong>ISBN:</strong> {{ book.isbn }}</p>
<p><strong>Language:</strong> {{ book.language }}</p>
<p><strong>Genre:</strong> {{ book.genre.all|join:", " }}</p>

<div style="margin-left:20px;margin-top:20px">
<h4>Copies</h4>

{% for copy in book.bookinstance_set.all %}
  <hr>
  <p class="{% if copy.status == 'a' %}text-success{% elif copy.status == 'd' %}text-danger{% else %}text-warning{% endif %}">{{ copy.get_status_display }}</p>
  {% if copy.status != 'a' %}<p><strong>Due to be returned:</strong> {{copy.due_back}}</p>{% endif %}
  <p><strong>Imprint:</strong> {{copy.imprint}}</p>
  <p class="text-muted"><strong>Id:</strong> <a href="{{ copy.get_absolute_url }}">{{copy.id}}</a></p>
{% empty %}
  <p>The library has no copies of this book.</p>
{% endfor %}
</div>
{% endblock %}


{% block sidebar %}
  {{ block.super }}

  {% if perms.catalog.change_book or perms.catalog.delete_book %}
  <hr>
  <ul class="sidebar-nav">
    {% if perms.catalog.change_book %}
      <li><a href="{% url 'book-update' book.id %}">Update Book</a></li>
    {% endif %}
    {% if not book.bookinstance_set.all and perms.catalog.delete_book %}
      <li><a href="{% url 'book-delete' book.id %}">Delete Book</a></li>
    {% endif %}
    </ul>
  {% endif %}

{% endblock %}
